public class Test02 {
    public String minWindow(String s, String t) {
        int[] hash1 = new int[128]; int count = 0;
        char[] ss = s.toCharArray(); char[] tt = t.toCharArray();
        for(char ch : tt) {
            if (hash1[ch] == 0) count++;
            hash1[ch]++;
        }
        int[] hash2 = new int[128];
        int minLen = Integer.MAX_VALUE, star = -1;
        for(int left = 0 , right = 0, kind = 0; right < ss.length; right++){
            char in = ss[right];
            hash2[in]++;
            if(hash2[in] == hash1[in]){
                kind++;
            }
            while(kind == count){
                if(right - left + 1 < minLen) {
                    star = left;
                    minLen = right - left + 1;
                }
                char out = ss[left];
                if(hash2[out] == hash1[out]){
                    kind--;
                }
                hash2[out]--;
                left++;
            }
        }
        if(star == -1) return new String();
        else return s.substring(star , star + minLen);
    }
}
